package com.herench.bs.handler;

import com.herench.bs.agent.IOutpatientClinicAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * com.herench.bs.handler
 * Created by wenkai on 2017/09/28/16:15
 *
 * @Software: IntelliJ IDEA
 */
@Component
@Handler(code = "100903" ,name="我的挂号详情")
public class LoadingRegistDetailsHandler extends AbstractMessageHandler {
    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        String channelCode = requestMessage.getArgsPropertyStringValue("sysCode");
        Assert.hasLength(channelCode,"sysCode 不可为空");
        String recordId = requestMessage.getArgsPropertyStringValue("recordId");
        Assert.hasLength(recordId,"recordId 不可为空");
        IOutpatientClinicAgent outpatientClinicAgent = getCleverClinicContext().getApplicationContext().getBean(IOutpatientClinicAgent.class);
        String hospitalCode = getCleverClinicContext().getHospitalCodeByChannelCode(channelCode);
        Map<String, Object> res = outpatientClinicAgent.queryRegistAndAppointDetail(channelCode, hospitalCode, recordId);
        responseMessage.setData(res);
        getPropertiesFromInvokerResultMap(responseMessage, res);
        return responseMessage;
    }
}
